package com.me.dogdog.controller


import com.me.dogdog.entity.SysMain
import com.me.dogdog.service.ISysMainService
import com.me.dogdog.vo.SysMainVO
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.beans.BeanUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Marblog
 * @since 2021-12-08
 */
@Tag(name = "SysMainController", description = "首页模块")
@RestController
@RequestMapping("/sys-main")
class SysMainController {
    @Autowired
    lateinit var sysMainService: ISysMainService

    @GetMapping("/all")
    fun getAll(): SysMain? {
        return sysMainService.list().random()
    }

    @PostMapping("add")
    fun add(@RequestBody sys: SysMainVO): SysMain? {
        val sysMain = SysMain()
        BeanUtils.copyProperties(sys, sysMain)
        sysMainService.save(sysMain)
        return sysMain
    }
}
